<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style media="screen">
            * {
                padding: 0;
                margin: 0;
            }
            .div1 {
                float: left;
                width: 100px;
                height: 100px;
                background: cyan;
                border: 1px solid #ccc;
            }
        </style>
    </head>
    <body>
        <div class="div1">div1</div>
        <div class="div1">div2</div>
        <div class="div1">div3</div>
        <div class="div1">div4</div>
        <div class="div1">div5</div>

    </body>
    <script type="text/javascript">
        var divs=document.querySelectorAll('.div1');
        for (var i=0; i<divs.length;i++) {
             divs[i].onclick = function() {
                 alert(this.innerHTML);
            }

        }

    </script>
</html>
